<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item,index) in arr">
               {{index+1}}、{{ item }}
            </li>
        </ul>
        <!-- 这个+会根据内容不同解释不同  上面数字+1， 下面为字符串合并-->
        <button @click="remove">减少</button>
        <h2 v-for="item in vegetables" v-bind:title="item.name">
            {{ item.name +1}} is {{item.price}} $
        </h2>
        <button @click="add">增加</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                arr:['beijing','shenzhen','shanghai'],
                vegetables:[
                    {name:"西兰花炒蛋",price:10},
                    {name:"蛋炒西兰花",price:9},
                    {name:"西兰炒花蛋",price:8},
                ],
            },
            methods: {
                add:function(){
                    this.vegetables.push({ name:"西炒兰花蛋" });
                },
                remove:function(){
                    this.vegetables.shift();
                },
            },
        })
    </script>

</body>
</html>